<template>
	<view class="content">
		<image :src="baseUrl+'/img/login/logo.png'" class="logo"></image>
		<view class="submitBox">
			<text class="submitText">一键授权</text>
			<button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" class="getPhoneNumber"></button>
			<view class="shouquan" @click="shouquan" v-show="isShouquan">
			</view>
		</view>
		<view class="xieyi">
			<image :src="selectIcon" class="select" @click="radioChange"></image>
			<text class="tongyiText" @click="$navto.navto('/pages/agreement/agreement')">我已阅读并同意《用户协议》</text>
		</view>
		<text class="back" @click="$back(1)">返回</text>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				baseUrl: this.$baseUrl,
				selectIcon: this.$baseUrl + '/img/login/select.png',
				radioIndex: 0,
				isShouquan: true,
			}
		},
		onShow() {
			wx.hideHomeButton();
			let that = this;
			
		},
		methods: {
			radioChange() {
				if (this.radioIndex == 0) {
					this.radioIndex = 1;
					this.isShouquan = false;
					this.selectIcon = this.baseUrl + 'img/login/selected.png'
				} else {
					this.radioIndex = 0;
					this.isShouquan = true;
					this.selectIcon = this.baseUrl + 'img/login/select.png'
				}
			},
			shouquan() {
				this.$toast('请先阅读并同意用户协议');
				return;
			},
			getPhoneNumber(e) {
				console.log(e.detail.code);
				this.$request.post('getUserPhone', {
					code: e.detail.code,
				}).then(res => {
					if (res.data.code == 10000) {
						this.$toast('登录成功');
						uni.navigateBack();
					} else {
						this.$toast('登录失败，请重试');
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.back{
		width: 200rpx;
		height: 60rpx;
		background-color: #121212;
		color: #FF6E5D;
		border-radius: 15rpx;
		margin-top: 50rpx;
		text-align: center;
		line-height: 60rpx;
		font-size: 26rpx;
	}
	.content {
		position: fixed;
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;
		background: url('https://qn-h5-video.guguan.net/juanjiahui/img/login/bg.jpg');
		background-size: 100% auto;

		.logo {
			width: 235rpx;
			height: 110rpx;
			margin-top: 450rpx;
			border-radius: 10rpx;
			z-index: 1;
		}

		.xieyi {
			position: relative;
			width: 100%;
			margin-top: 75rpx;
			display: flex;
			align-items: center;
			box-sizing: border-box;
			z-index: 1;
			justify-content: center;

			.select {
				width: 30rpx;
				height: 30rpx;
			}

			.tongyiText {
				margin-left: 25rpx;
				font-size: 24rpx;
				font-size: #121212;
			}
		}

		.submitBox {
			position: relative;
			width: 650rpx;
			height: 80rpx;
			margin-top: 130rpx;
			border-radius: 10rpx;
			background: #000000;
			display: flex;
			flex-direction: row;
			justify-content: center;
			align-items: center;
			z-index: 1;

			.submitText {
				font-size: 26rpx;
				color: #FF6E5D;
				letter-spacing: 2px;
			}

			.getPhoneNumber,
			.shouquan {
				position: absolute;
				width: 100%;
				height: 100%;
				left: 0;
				top: 0;
				opacity: 0;
			}
		}
	}
</style>